home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / linux_bo / netboot.zoo / booter.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-05  |  2.1 KB  |  117 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4. #include "protocol.h"
  5. #include "bootinc.h"
  6.  
  7. /* Copyright 1993 Jamie Honan
  8.    May be freely copied, sold and modified.
  9. */
  10.  
  11. int 
  12. xinch(char *s)
  13. {
  14.     int             val;
  15.     int             nseen;
  16.  
  17.     nseen = 0;
  18.     val = 0;
  19.     for (; *s; s++)
  20.     {
  21.         if (!nseen && isspace(*s))
  22.             continue;
  23.         if (!nseen)
  24.         {
  25.             if (*s == '0')
  26.             {
  27.                 nseen = 1;
  28.                 continue;
  29.             }
  30.             nseen = 2;
  31.         }
  32.         if (nseen == 1 && (*s == 'x' || *s == 'X'))
  33.         {
  34.             nseen = 2;
  35.             continue;
  36.         }
  37.         if (*s >= 'a' && *s <= 'f')
  38.             val = val * 16 + (*s - 'a') + 10;
  39.         else if (*s >= 'A' && *s <= 'F')
  40.             val = val * 16 + (*s - 'A') + 10;
  41.         else if (*s >= '0' && *s <= '9')
  42.             val = val * 16 + (*s - '0');
  43.         else
  44.             break;
  45.     }
  46.     return val;
  47. }
  48.  
  49. main(argc, argv)
  50. int             argc;
  51. char           *argv[];
  52.  
  53. {
  54.     int             irq,
  55.                     ioaddr,
  56.                     haddr,
  57.                     extra;
  58. static    char            ifname[30];
  59.     char           *argp;
  60.     int             argn;
  61.  
  62.     argn = 0;
  63.     ifname[0] = 'w';
  64.     ifname[1] = 'd';
  65.     ifname[2] = '\0';
  66.  
  67.     irq = 10;
  68.     ioaddr = 0x280;
  69.     haddr = 0xd000;
  70.     extra = 0;
  71.  
  72.  
  73. /*    n_printf(" ds %x cs %x ss %x, sp %x, start_of_data %x, end_of_data %x, end_of_bss %x\n",
  74.         segds(), segcs(), segss(), &argn, &start_of_data, &end_of_data,&end_of_bss);
  75.     
  76.     n_putscrlf("booter ... ");
  77.  
  78.     dos_exit(0);
  79. */
  80.     while (--argc > 0)
  81.     {
  82.         argn++;
  83.         argp = argv[argn];
  84.         if (*argp == '-' || *argp == '?')
  85.         {
  86.             fprintf(stderr, "usage: %s [ifname [irq [ioaddr [hardaddr [extra]]]]\n", argv[0]);
  87.             exit(1);
  88.         }
  89.         switch (argn)
  90.         {
  91.         case 1:
  92.             strncpy(ifname, argp, sizeof(ifname) - 1);
  93.             ifname[sizeof(ifname) - 1] = '\0';
  94.             break;
  95.         case 2:
  96.             irq = xinch(argp);
  97.             break;
  98.         case 3:
  99.             ioaddr = xinch(argp);
  100.             break;
  101.         case 4:
  102.             haddr = xinch(argp);
  103.             break;
  104.         case 5:
  105.             extra = xinch(argp);
  106.             break;
  107.         default:
  108.             fprintf(stderr, "Too many params on command line\n");
  109.             fprintf(stderr, "usage: %s [ifname [irq [ioaddr [hardaddr [extra]]]]\n", argv[0]);
  110.             exit(1);
  111.         }
  112.     }
  113.     netparms(irq, haddr, ioaddr, extra);
  114.     do_boot_process(ifname);
  115.     dos_exit(0);
  116. }
  117.